<?php

Yii::import('application.models._base.BaseTerima');
class Terima extends BaseTerima
{
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }
    public static function getDataByPO($select, $id)
    {
        $criteria = new CDbCriteria();
        $criteria->select = $select;
        $criteria->addCondition('po_id = :po_id');
        $criteria->params = array('po_id' => $id);
        $model = Terima::model()->findAll($criteria);
        $total = Terima::model()->count($criteria);
        return array('model' => $model, 'total' => $total);
    }
    public function beforeValidate()
    {
        $this->tdate = new CDbExpression('NOW()');
        $this->id_user = Yii::app()->user->getId();
        return parent::beforeValidate();
    }
}